package com.t168.appinfo.service.reception.appinfo.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.t168.appinfo.dao.reception.appinfo.AppInfoMapper;
import com.t168.appinfo.entity.AppInfo;
import com.t168.appinfo.entity.AppVersion;
import com.t168.appinfo.service.reception.appinfo.AppInfoService;



@Service("appInfoService")
public class AppInfoServiceImpl implements AppInfoService {

	@Resource(name="appInfoMapper")
	private AppInfoMapper appInfoMapper;
	
	public AppInfoMapper getAppInfoMapper() {
		return appInfoMapper;
	}

	public void setAppInfoMapper(AppInfoMapper appInfoMapper) {
		this.appInfoMapper = appInfoMapper;
	}




	@Override
	public List<AppInfo> getAppInfo(String level1, String level2,
			String level3, String softwareName, String flatformId,String status,
			Integer pageIndex, Integer pageCount) {
		int beginNo = (pageIndex -1)* pageCount;
		return appInfoMapper.getAppInfo(level1, level2, level3, softwareName,  flatformId, status, beginNo, pageCount);
	}

	@Override
	public int getAppInfoCount(String level1, String level2, String level3,
			String softwareName, String flatformId, String status) {
		// TODO Auto-generated method stub
		return appInfoMapper.getAppInfoCount(level1, level2, level3, softwareName, flatformId, status);
	}

	@Override
	public boolean addAppInfo(AppInfo appInfo) {
		boolean flag = false;
		if(appInfoMapper.addAppInfo(appInfo) > 0){
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean apkExist(String apkName) {
		boolean flag = false;
		if(appInfoMapper.apkExist(apkName) > 0){
			flag = true;
		}
		return flag;
	}

	@Override
	public AppInfo getAppInfoViewById(int id) {
		// TODO Auto-generated method stub
		return appInfoMapper.getAppInfoViewById(id);
	}

	@Override
	public boolean modifyAppInfoSave(AppInfo appInfo) {
		boolean flag = false;
		if(appInfoMapper.modifyAppInfoSave(appInfo) > 0){
			flag = true;
		}
		return flag;
	}
	
	
	public boolean modifyAppVersionId(int id,int versionId){
		boolean flag = false;
		if(appInfoMapper.modifyAppVersionId(id, versionId) > 0){
			flag  = true;
		}
		return flag;
	}
	
	
	@Override
	public AppInfo historyVersion(int appId) {
		// TODO Auto-generated method stub
		return appInfoMapper.historyVersion(appId);
	}

	@Override
	public boolean delAppInfoById(int appId) {
		boolean flag = false;
		if(appInfoMapper.delAppInfoById(appId) > 0){
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean modifyAppInfoStatus(int id, String saleSwitch) {
		boolean flag = false;
		if(appInfoMapper.modifyAppInfoStatus(id, saleSwitch)>0){
			flag = true;
		}
		return flag;
	}



}
